<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
   String url = request.getScheme()+"://"+ request.getServerName()+request.getRequestURI()+"?"+request.getQueryString();  
%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
		<!--[if gt IE 8]>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />        
    <![endif]-->

		<title>报名系统</title>
		<%@include file="res.jsp"%>
		
		<script type="text/javascript">
			function enter_export()
			{ 
				var singupId = $("#singupId").val() ;  

				if(singupId.length == 0)
				{
					return ; 
				}
				 
				$("#export_btn").removeClass("btn btn-primary")
								.addClass("btn btn-primary disabled")
								.text("正在导出...") ; 

				//singup_export.action
				$.get("<%=basePath%>page/singup_exportEnter.action?id="+singupId+"&time="+(new Date().valueOf()),function(data,status){
				    if(status == 'success')
				    {
				    	alert("导出成功,请到【所有报名】下载") ; 
				    	$("#export_btn").removeClass("btn btn-primary disabled")
							.addClass("btn btn-primary")
							.text("导出") ;  
				    }
				 });
				
			}
		</script>

	</head>
	<body>

		<jsp:include page="header.jsp"></jsp:include>

		<jsp:include page="menu.jsp"></jsp:include>

		<jsp:include page="com_bbs.jsp"></jsp:include>
		<div class="content">

			<div class="row-fluid">
				<div class="span12">
				
					<c:if test="${!empty currentSingupId}">
						<div class="widget"> 
							<div class="wrapper">
								<form action="page/singup_search.action" method="get"  id="validate">
									<div class="input-append input-prepend">
										<input type="hidden" name="singupId" value="${currentSingupId }"/>
										<span class="add-on"><span class="icon-search"></span> </span>
										<input type="text" name="keyword"  class="validate[maxSize[10]]" value="${keyword }" placeholder="搜索..." >
										<button type="submit" class="btn btn-primary">
											搜索
										</button> 
									</div>
								</form>
							</div> 
						</div>
					</c:if>
					
					<script type="text/javascript"> 
						function opt_properties(sel) {
							var singupId = sel.options[sel.options.selectedIndex].value;
							if (singupId.length > 0) { 
								location.href = "<%=basePath%>page/singup_search.action?singupId="+singupId ;
							}
						}

						function delEnter(btn, id)
						{  
							if (!confirm("确认要删除？")) {
								return  ; 
							}
							
							$(btn).parent().parent().remove() ; 
							
							var url = "<%=basePath%>page/singup_removeEnter.action?id="+id+"&time="+(new Date().valueOf()) ; 
							$.get(url, function(data,state){
							    if(state == 'success')
							    { 
							    }
							    else
							    {
								    alert("网络出现异常") ; 
							    }
							});
						}
						
						function tagEnter(id)
						{  
							var url = "<%=basePath%>page/singup_tagEnter.action?id="+id+"&time="+(new Date().valueOf()) ; 
							$.get(url, function(data,state){
							    if(state == 'success')
							    {
								    //刷新页面
							    	window.location.reload(); 
							    }
							    else
							    {
								    alert("网络出现异常") ; 
							    }
							}); 
							
							//<span class="label label-important">offline</span>
						}
					</script>
					<div class="widget">
						<div class="toolbar">
							<div class="left">
								<select name="singupId" id="singupId" onchange="opt_properties(this)">
									<option value="">
										选择报名
									</option>
									<c:forEach items="${singups}" var="singup">
										<c:choose>
											<c:when test="${singup.id == currentSingupId}">
												<option value="${singup.id }" selected="selected"> 
													${singup.title }
												</option>
											</c:when>
											<c:otherwise>
												<option value="${singup.id }"> 
													${singup.title }
												</option>
											</c:otherwise>
										</c:choose>
									</c:forEach>
								</select> 
							</div>
							<div class="right" style="width: 100px;">
								 <a  class="btn btn-primary" id="export_btn" onclick="enter_export(this)">&nbsp;导出&nbsp;</a>
							</div>
						</div>

						<div class="block-fluid" id="enter_ajax"> 
							<c:choose>
								<c:when test="${!empty Allenters}">
								 	<table width="100%" cellspacing="0" cellpadding="0" class="table-hover">
										<thead>
											<tr> 
													<th width="Infinity%">
														排序
													</th> 
													<th width="Infinity%">
														报名用户
													</th> 
													<th width="Infinity%">
														报名
													</th> 
													<th width="Infinity%">
														报名时间
													</th> 
													<th> 
														操作
													</th>  
											</tr>
										</thead>
										<tbody> 
											<c:forEach items="${Allenters}" var="enter" varStatus="state">
												<tr> 
														<td width="Infinity%">
															<a>${state.index + 1}</a>
														</td>
														<td width="Infinity%">
															<a>${enter.enterName }</a>
														</td>
														<td width="Infinity%">
															<a>${enter.singupName }</a>
														</td> 
														<td width="Infinity%">
															<a>${enter.addTime }</a>
														</td>
													 
													<td class="TAC">  
														<c:choose>
															<c:when test="${enter.tag == 1}">
																<span class="label label-important">
																	<a  class="tip" data-original-title="取消标记" onclick="tagEnter('${enter.id}');"  style="cursor:pointer">
																		<span class="icon-check"></span>
																	</a>
																</span>
																&nbsp;&nbsp;
															</c:when>
															<c:otherwise> 
																	<a  class="tip" data-original-title="标记" onclick="tagEnter('${enter.id}');"  style="cursor:pointer">
																		<span class="icon-edit"></span>
																	</a> 
																&nbsp;&nbsp;
															</c:otherwise>
														</c:choose>
				                                        <a  class="tip" data-original-title="删除" onClick="delEnter(this,'${enter.id}');">
				                                        	<span class="icon-trash"></span>
				                                        </a>
				                                    </td>
												</tr> 
												</c:forEach>
										</tbody>
									</table>
								</c:when>
								<c:otherwise>
									<table width="100%" cellspacing="0" cellpadding="0"
										class="table-hover">
										<thead>
											<tr> 
												<c:set value="${ 100/fn:length(headerProp)}" var="thwidth"></c:set>
												<c:forEach items="${headers}" var="prop">
													<th width="${thwidth }%"> 
														<c:choose>
															<c:when test="${empty prop.alias}">
							                            		${prop.value }
							                            	</c:when>
															<c:otherwise>
							                            		${prop.alias }
							                            	</c:otherwise>
														</c:choose> 
													</th>
												</c:forEach>
												<c:if test="${!empty pageBean}">
													<th> 
														操作
													</th>
												</c:if>
												
											</tr>
										</thead>
										<tbody>
											<c:forEach items="${enters}" var="enter">
												<tr>
													<c:forEach items="${headers}" var="prop">
														<td width="${thwidth }%">
															<c:choose>
																<c:when test="${prop.type == 'file'}"> 
																	<c:choose>
																		<c:when test="${empty enter.map[prop.name] || fn:length(enter.map[prop.name]) < 32}">
																			<a href="img/users/default.jpg" class="fb" rel="group"> 
																				<img src="img/users/default.jpg" width="25px" height="25px" class="img-polaroid" align="left">
																			</a>
																		</c:when>
																		<c:otherwise> 
																			<a href="${enter.map[prop.name]}" class="fb" rel="group"> 
																				<img src="${enter.map[prop.name]}" width="25px" height="25px" class="img-polaroid" align="left">
																			</a>
																		</c:otherwise>
																	</c:choose> 
																</c:when>
																<c:otherwise>
																	<a>${enter.map[prop.name]}</a>
																</c:otherwise>
															</c:choose>
															
														</td>
													</c:forEach>
													<td class="TAC">  
														<c:choose>
															<c:when test="${enter.tag == 1}">
																<span class="label label-important">
																	<a  class="tip" data-original-title="取消标记" onclick="tagEnter('${enter.id}');"  style="cursor:pointer">
																		<span class="icon-check"></span>
																	</a>
																</span>
																&nbsp;&nbsp;
															</c:when>
															<c:otherwise> 
																	<a class="tip" data-original-title="标记" onclick="tagEnter('${enter.id}');"  style="cursor:pointer">
																		<span class="icon-edit"></span>
																	</a> 
																&nbsp;&nbsp;
															</c:otherwise>
														</c:choose> 
				                                        <a  class="tip" data-original-title="删除" onClick="delEnter(this,'${enter.id}');"><span class="icon-trash"></span></a>
				                                    </td>
												</tr>
											</c:forEach>
		
										</tbody>
									</table>
								</c:otherwise>
							</c:choose>
							
						</div>
						<div class="toolbar bottom">
							<c:if test="${pageBean != null}">
								<jsp:include page="pager_singup.jsp"></jsp:include>
							</c:if>
						</div> 
					</div>

				</div>
			</div>

		</div>

	</body>
</html>
